{extend name="layout/iframe" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/layui-formSelects/formSelects-v4.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>调价范围</label>
            <div class="layui-input-block">
                <select name="range" class="range" lay-verify="required" lay-filter="range" data-value="">
                    <option value="">请选择</option>
                    <option value="1">商品目录+APP/小程序+所有门店</option>
                    <option value="2">商品目录+APP/小程序</option>
                    <option value="3">商品目录+所有门店</option>
                    <option value="4">APP/小程序</option>
                    <option value="5">指定门店</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text store_ids-div" style="display: none;">
            <label class="layui-form-label"><span class="required">*</span>选择门店</label>
            <div class="layui-input-block">
                <select name="store_ids" id="storeIds" xm-select="storeIds" lay-verify="store_ids">
                    {foreach name="storeList" item="store" key="storeKey"}
                        <option value="{$store.id}">{$store.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>调价商品</label>
            <div class="layui-input-block">
                <input type="hidden" class="layui-input product_ids" name="product_ids" value="" lay-verify="product_ids">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid select-products" style="float: right;">选择商品</button>
            </div>
            <div class="product_price_item" style="display: none;">
                <input type="hidden" class="layui-input" name="product_id[]" value="">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>生效日期</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input lay_date" name="effective_date" lay-verify="required" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="remark" maxlength="100" placeholder="" autocomplete="off">
            </div>
        </div>

        <input type="hidden" name="id" value="">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">

<input type="hidden" class="select_products_url" value="{:url('admin/productprice/selectproducts')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/pages/js/productprice.js" type="text/javascript"></script>
<script>
    layui.use(['layer', 'laydate'], function(){
        var $ = layui.jquery,
            laydate = layui.laydate;

        // 执行一个laydate实例
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        strDate += 1;
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var startDate = year + seperator1 + month + seperator1 + strDate;
        //console.log(startDate);
        var layDate = laydate.render({
            elem: '.lay_date',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click',
            min : startDate,
            done: function(value, date){
                //
            }
        });
    });
</script>
{/block}